use anyhow::*;
use fs_extra::copy_items;
use fs_extra::dir::CopyOptions;
use std::env;

fn main() -> Result<()> {
    println!("------ custom building ------");    
    println!("cargo:rerun-if-changed=src/models/*");

    let out_dir = env::var("OUT_DIR")?;
    println!("OUT_DIR: {}", out_dir);

    let mut paths_to_copy = Vec::new();
    paths_to_copy.push("src/models");
    println!("paths_to_copy: {:?}", paths_to_copy);
    
    let mut copy_options = CopyOptions::new();
    copy_options.overwrite = true;
    copy_items(&paths_to_copy, out_dir, &copy_options)?;
    Ok(())
}
